package com.hongmeng.operater.service.impl;

import java.util.List;
import com.hongmeng.common.utils.DateUtils;
import com.hongmeng.operater.domain.AddLeaveMessage;
import com.hongmeng.operater.domain.LeaveMessage;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hongmeng.operater.mapper.HmLeaveMessageMapper;
import com.hongmeng.operater.domain.HmLeaveMessage;
import com.hongmeng.operater.service.IHmLeaveMessageService;

/**
 * 留言Service业务层处理
 *
 * @author hongmeng
 * @date 2021-01-21
 */
@Service
public class HmLeaveMessageServiceImpl implements IHmLeaveMessageService
{
    @Autowired
    private HmLeaveMessageMapper hmLeaveMessageMapper;

    /**
     * 查询留言
     *
     * @param id 留言ID
     * @return 留言
     */
    @Override
    public HmLeaveMessage selectHmLeaveMessageById(Integer id)
    {
        return hmLeaveMessageMapper.selectHmLeaveMessageById(id);
    }

    /**
     * 查询留言列表
     *
     * @param hmLeaveMessage 留言
     * @return 留言
     */
    @Override
    public List<HmLeaveMessage> selectHmLeaveMessageList(LeaveMessage hmLeaveMessage)
    {
        return hmLeaveMessageMapper.selectHmLeaveMessageList(hmLeaveMessage);
    }

    /**
     * 新增留言
     *
     * @param addLeaveMessage 留言
     * @return 结果
     */
    @Override
    public int insertHmLeaveMessage(AddLeaveMessage addLeaveMessage) {
        HmLeaveMessage hmLeaveMessage = new HmLeaveMessage();
        BeanUtils.copyProperties(addLeaveMessage, hmLeaveMessage);//复制实体类a复制到b
        hmLeaveMessage.setCreateTime(DateUtils.getNowDate());
        return hmLeaveMessageMapper.insertHmLeaveMessage(hmLeaveMessage);
    }

    /**
     * 修改留言
     *
     * @param hmLeaveMessage 留言
     * @return 结果
     */
    @Override
    public int updateHmLeaveMessage(HmLeaveMessage hmLeaveMessage)
    {
        hmLeaveMessage.setUpdateTime(DateUtils.getNowDate());
        return hmLeaveMessageMapper.updateHmLeaveMessage(hmLeaveMessage);
    }

    /**
     * 批量删除留言
     *
     * @param ids 需要删除的留言ID
     * @return 结果
     */
    @Override
    public int deleteHmLeaveMessageByIds(Integer[] ids)
    {
        return hmLeaveMessageMapper.deleteHmLeaveMessageByIds(ids);
    }

    /**
     * 删除留言信息
     *
     * @param id 留言ID
     * @return 结果
     */
    @Override
    public int deleteHmLeaveMessageById(Integer id)
    {
        return hmLeaveMessageMapper.deleteHmLeaveMessageById(id);
    }
}
